#pragma once
#ifndef __G_REF_COUNTED_H__
#define __G_REF_COUNTED_H__

#include "GTypes.h"
#include "GCounter.h"

namespace GUtil
{
	// Intrusive ref counting base class
	class GRefCounted
	{
	protected:
		typedef GAtomicCounter<GUInt32> CounterType;	

		mutable CounterType	RefCount;
		mutable CounterType	LinkCount;

							GRefCounted();
		virtual				~GRefCounted();

	public:
		GUInt32				GetRefCount() const;
		GUInt32				GetLinkCount() const;

		GUInt32				RefIncrease();
		GUInt32				RefDecrease();
		
		GUInt32				LinkIncrease();
		GUInt32				LinkDecrease();

		const GRefCounted&	operator = (const GRefCounted& Other);
	
	};

}

#endif // __G_REF_COUNTED_H__